#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments.  The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".

./gradlew spotlessCheck
result=$?
printf "the spotlessCheck result code is $result \n"
if [[ "$result" = 0 ]] ; then
    echo "\033[32mSpotlessCheck Pass!!\033[0m"
    exit 0
else
    ./gradlew spotlessApply
    echo "\033[31mSpotlessCheck Failed!!代码格式有问题;\033[0m"
    exit 1
fi